<?php session_start(); ?>
<?php include "libfunc.php";?>
<?php if (!empty($_SESSION['admUser']) && !empty($_SESSION['admPass'])) { ?>
<html>
 <head>
  <title>.: Admin Room ClothingCorp :.</title>
  <link href="admInc/cssMainStyle.css" type="text/css" rel="stylesheet">
  <link href="admInc/cssTableStyle.css" type="text/css" rel="stylesheet">
  <link href="admInc/cssAdditionStyle.css" type="text/css" rel="stylesheet">
  <link href="admInc/cssTableNavigation.css" type="text/css" rel="stylesheet">
 </head>
 <body class="fix">
  <div id="wrapper">
   <div id="header">
    <div class="titleHeader"><center>
     <img src="image/logo2.png" border="0">
	</div><!-- titleHeader //-->
	<div class="subTitleHeader"><center>
	 - Website Administrator Control Panel -
	</div><!-- subTitleHeader //-->
   </div><!-- header //--></center>
   <div id="mainContent">
    <div id="leftColumn">
	 <div class="navigation">
	  <table border="0" width="100%" bgcolor="white">
	  <tr>
	    <td class="headerTable" align="center"><b>Admin Page</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="adminLayout.php"> Halaman Utama</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="newInformation.php"> Informasi Terkini</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="LogOut.php" onClick="return confirm('Apakah Anda benar-benar akan keluar dari halaman Admin ?')"> Keluar</a></td>
	  </tr>
	  <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Kategori</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="tambah_kategori.php"> Tambah Kategori</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_kategori.php"> View Kategori</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_kategori.php"> Pencarian Kategori</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Member</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="tambah_member.php"> Tambah Member</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_member.php"> View Member</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_member.php"> Pencarian Member</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Produk</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="tambah_produk.php"> Tambah Produk</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_produk.php"> View Produk</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_produk.php"> Pencarian Produk</a></td>
	  </tr>
	  <tr>
		<td></td>
	  </tr>
	  <tr>
		<td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Request Produk</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_request.php"> View Request</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_request.php"> Pencarian Request</a></td>
	  </tr>
	  <tr>
		<td></td>
	  </tr>
	  <tr>
		<td></td>
	  </tr>
	  <tr>
	    <td class="headerTable" align="center"><b>Data Pesanan</b></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="view_pesanan.php"> View Pesanan</a></td>
	  </tr>
	  <tr>
	    <td><img src="image/tag_blue.png"><a href="pencarian_pesanan.php"> Pencarian Pesanan</a></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
      <tr>
	    <td></td>
	  </tr>
	</table>
	 </div><!-- navigation //-->
	</div><!-- leftColumn //-->
	<div id="rightColumn">
	 <div class="content">
	<?php 
	    $id = $_GET[id];
		//------------------------------ Koneksi ke database
		$link = koneksi_db();
		$sql = "select * from dtbuku where id_buku = '$id'";
		$res = mysql_query($sql,$link);
		$cek = mysql_num_rows($res);
		//----------------------- end of koneksi ke db
				
		//------------------- Pengecekan apa data ada ? 
		if ( $cek<=0 ) { //------------------------ Jika member kosong
	?>
		 <div id="keterangan">
          <fieldset>
          <legend>Keterangan</legend>
           Data produk Kosong. <br />
           Silakan Ulangi!!!
          </fieldset>	  
         </div>
	<?php
        }else{ 
		  $data = mysql_fetch_array($res);
	?>
	     <form action="proses_edit_buku.php" method="post" enctype="multipart/form-data">
         <fieldset>
          <legend>Form Edit Buku</legend>
		  <input type="hidden" name="id_buku" value="<?php echo $id; ?>">
          <table class="tableTask">
		   <tr>
			  <td width="88">Pilih Penerbit</td>
			  <td width="240">
			    <select name="penerbit" class="selectStyle">
				<?php 
				  $link = koneksi_db();
				  $sql = "select * from dtproduk";
				  $res_penerbit = mysql_query($sql,$link);
				  
				  while ($dt_penerbit = mysql_fetch_array($res_produk)) {
				    if($data['id_produk'] == $dt_produk['id_produk']){
			?>         <option value="<?php echo $dt_produk['id_produk']; ?>" selected><?php echo $dt_produk['nama']; ?></option>
			<?php 	}else{
			?>         <option value="<?php echo $dt_produk['id_produk']; ?>"><?php echo $dt_produk['nama']; ?></option>
			<?php	}
                  }
			?>  </select>
			  </td>
              <td width="236" class="trInformation">&laquo; Silakan memilih produk baju</td>
			</tr>
			<tr>
			  <td>Pilih Kategori</td>
			  <td>
			    <select name="kategori" class="selectStyle">
				<?php 
				  $link = koneksi_db();
				  $sql = "select * from dtkategori";
				  $res_kategori = mysql_query($sql,$link);
				  
				  while ($dt_kategori = mysql_fetch_array($res_kategori)) {
				    if($data['id_kategori'] == $dt_kategori['id_kategori']){?>
  	                  <option value="<?php echo $dt_kategori['id_kategori']; ?>" selected><?php echo $dt_kategori['nama']; ?></option>
			<?php   }else{
			?>        <option value="<?php echo $dt_kategori['id_kategori']; ?>"><?php echo $dt_kategori['nama']; ?></option>
			<?php   }	
				  }
			?>  </select>
			  </td>
              <td class="trInformation">&laquo; Silakan memilih kategori produk baju</td>
			</tr>
			<tr>
			  <td>Judul Buku</td>
			  <td><input type="text" name="judul" size="30" value="<?php echo $data['judul']; ?>" class="textStyle"></td>
			  <td class="trInformation">&laquo; Silakan ubah judul produk</td>
			</tr>
			<tr>
			  <td>Harga</td>
			  <td><input type="text" name="harga" size="30" value="<?php echo $data['harga']; ?>" class="textStyle"></td>
			  <td class="trInformation">&laquo; Silakan ubah harga produk</td>
			</tr>
			<tr>
			  <td>Gambar</td>
			  <td><input type="file" name="fupload" size="24" value="<?php echo $data['filegambar']; ?>" class="textStyle"></td>
              <td class="trInformation">&laquo; Silakan ganti gambar produk</td>
			</tr>
			<tr>
			  <td>Stok</td>
			  <td><input type="text" name="stok" size="30" value="<?php echo $data['stok']; ?>" class="textStyle"></td>
			  <td class="trInformation">&laquo; Silakan ubah stok produk</td>
			</tr>
			<tr>
			  <td>Diskon</td>
			  <td><input type="text" name="diskon" size="30" value="<?php echo $data['diskon']; ?>" class="textStyle"></td>
			  <td class="trInformation">&laquo; Silakan ubah diskon produk</td>
			</tr>
            <tr>
              <td>Dihapus</td>
              <td>
                <input type="radio" name="dihapus" value="Y" <?php if ($data['dihapus']=="Y") echo "checked"; ?> >Ya
                <input type="radio" name="dihapus" value="T" <?php if ($data['dihapus']=="T") echo "checked"; ?> >Tidak
              </td>
              <td class="trInformation">&laquo; Silakan ubah status dihapus produk</td>
            </tr>
            <tr>
              <td>Dijual</td>
              <td>
                <input type="radio" name="dijual" value="Y" <?php if ($data['dijual']=="Y") echo "checked"; ?> >Ya
                <input type="radio" name="dijual" value="T" <?php if ($data['dijual']=="T") echo "checked"; ?> >Tidak
              </td>
              <td class="trInformation">&laquo; Silakan ubah status dijual produk</td>
            </tr>
            </table>
            <table class="tableTask">
            <tr>
              <td>Deskripsi</td>
            </tr>
            <tr>
			  <td><textarea name="deskripsi" rows="5" cols="80" class="textStyle"><?php echo $data['deskripsi']; ?></textarea></td>
			</tr>
			<tr>
			  <td colspan="2" align="center">
			    <input type="submit" name="tbl_tambah" value="Update" class="buttonStyle">
				<input type="button" name="update" value="Batal" onClick="javascript:history.back()" class="buttonStyle">
			  </td>
			  <td></td>
			</tr>
          </table>
          </fieldset>
		</form>
      <div id="keterangan">
       <fieldset>
        <legend>Keterangan</legend>
         Silakan Edit atau Ubah Data Produk<br>
         Biarkan field data Produk, bila tidak ingin diubah.
       </fieldset>
      </div>
	<?php
	  }
	?>
	 </div><!-- content //-->
	</div><!-- rightColumn //-->
   </div><!-- mainContent //-->
  </div><!-- wrapper //-->
 </body>
</html>
<?php
}else{
  echo "<script language='javascript'>alert('Silakan Sign In Terlebih Dahulu')</script>";
  echo "<script language='javascript'>window.location = '../admin/'</script>";
}